home *** CD-ROM | disk | FTP | other *** search
/ The Sunday Times: The Month 2004 August / The Sunday Times - The Month 2004-08.iso / pc / engine / shell / shell.swf / scripts / DefineSprite_106 / frame_1 / DoAction.as
Text File  |  2004-07-06  |  6KB  |  212 lines

  1. function load()
  2. {
  3.    loaded = false;
  4.    xmlData = new XML();
  5.    xmlData.ignoreWhite = true;
  6.    xmlData.onLoad = function(success)
  7.    {
  8.       delete this.onLoad;
  9.       loaded = true;
  10.       drawLayout();
  11.       onDataLoaded();
  12.    };
  13.    var strFile = "xml/content/" + Tardis.ActiveSection.id + "/" + Tardis.ActiveItem.attributes.xmlfile + ".xml";
  14.    xmlData.path = strFile;
  15.    strFile = Tardis.ASSETS_FOLDER + strFile + (Tardis.PLAY_MODE != "browser" ? "" : "?random=" + random(1000000));
  16.    xmlData.load(strFile);
  17. }
  18. function exit()
  19. {
  20.    Tardis.debug.addProcess("clickMainNav","Tardis : exit()");
  21.    delete xmlData;
  22.    loaded = false;
  23.    gotoAndStop(2);
  24.    Tardis.onItemExit();
  25. }
  26. function showMask(v)
  27. {
  28.    trace("setting templateMask_mc.visible : " + !v);
  29.    templateMask_mc._visible = v;
  30. }
  31. function show()
  32. {
  33.    setShowHide(true);
  34. }
  35. function hide()
  36. {
  37.    setShowHide(false);
  38. }
  39. function interrupt()
  40. {
  41.    setInterruptResume(false);
  42. }
  43. function resume()
  44. {
  45.    setInterruptResume(true);
  46. }
  47. function loadBespokeSection()
  48. {
  49.    var S = Tardis.ActiveSection;
  50.    gotoAndStop("l_" + S.layout);
  51.    trace("I am loadBespokeSection\t()");
  52.    var mc = mcTL;
  53.    if(S.sandbox != "true")
  54.    {
  55.       mc.loadMovie(Tardis.ASSETS_FOLDER + "bespoke/" + S.file);
  56.    }
  57.    else
  58.    {
  59.       nodeSectionData = new XML("<bespoke width=\"" + S.width + "\" height=\"" + S.height + "\">" + S.file + "</bespoke>").firstChild;
  60.       mc.onLoad;
  61.       mc.onReady;
  62.       mc.onReady = function()
  63.       {
  64.          trace("Hello - I\'m onReady()");
  65.          this.nodeData = Tardis.template.nodeSectionData;
  66.          delete Tardis.template.nodeSectionData;
  67.          this.onReady = null;
  68.          this.init();
  69.          this._parent.onReady();
  70.       };
  71.       mc.loadMovie(Tardis.ENGINE_FOLDER + "modules/bespoke.swf");
  72.    }
  73. }
  74. function setShowHide(flag)
  75. {
  76.    trace("!!!! Tardis.template.setShowHide(" + flag + ")");
  77.    var obj;
  78.    for(var o in this)
  79.    {
  80.       obj = this[o];
  81.       if(typeof obj == "movieclip")
  82.       {
  83.          obj._visible = flag;
  84.          !flag ? obj.interrupt() : obj.resume();
  85.       }
  86.    }
  87. }
  88. function setInterruptResume(flag)
  89. {
  90.    var obj;
  91.    for(var o in this)
  92.    {
  93.       obj = this[o];
  94.       if(typeof obj == "movieclip")
  95.       {
  96.          !flag ? obj.interrupt() : obj.resume();
  97.       }
  98.    }
  99. }
  100. function drawLayout()
  101. {
  102.    var ndTemplate = xmlData.firstChild.byName("template");
  103.    var strLayout = ndTemplate.attributes.layout;
  104.    gotoAndStop("l_" + strLayout);
  105. }
  106. function loadModules()
  107. {
  108.    Tardis.debug.addProcess("loadModules","template.loadModules()");
  109.    if(loaded == false || Tardis.sideMenu.animating == true)
  110.    {
  111.       Tardis.debug.addProcess("loadModules","-- side menu still animating - try again");
  112.       return undefined;
  113.    }
  114.    ndTemplate = xmlData.firstChild.byName("template");
  115.    pageEditVars = new LoadVars();
  116.    pageEditVars.layout = ndTemplate.attributes.layout;
  117.    pageEditVars.xml_path = xmlData.path;
  118.    ndContent = xmlData.firstChild.byName("content");
  119.    modulePath = Tardis.ENGINE_FOLDER + "modules/";
  120.    nmModules = ndTemplate.childNodes.length;
  121.    nmModulesReady = 0;
  122.    nmModuleCurrent = 0;
  123.    loadNextModule();
  124. }
  125. function loadNextModule()
  126. {
  127.    Tardis.debug.addProcess("loadModules","template.loadNextModule()");
  128.    if(nmModuleCurrent >= nmModules)
  129.    {
  130.       Tardis.debug.addProcess("loadModules","-- all modules loaded");
  131.       Tardis.debug.addProcess("loadModules","-- now load advert...");
  132.       Tardis.loadAdvertButton();
  133.       return undefined;
  134.    }
  135.    var ndModule = ndTemplate.childNodes[nmModuleCurrent];
  136.    var posName = ndModule.attributes.position;
  137.    var mcPosition = this["mc" + posName];
  138.    var strType = ndModule.attributes.type;
  139.    var strNdPath = ndModule.attributes.nodepath;
  140.    var ndModuleData = ndContent.byPath(strNdPath);
  141.    objModuleInitObjects[mcPosition] = {nodeData:ndModuleData};
  142.    pageEditVars["mod_" + nmModuleCurrent + "_position"] = posName;
  143.    pageEditVars["mod_" + nmModuleCurrent + "_type"] = strType;
  144.    pageEditVars["mod_" + nmModuleCurrent + "_nodepath"] = strNdPath;
  145.    pageEditVars["mod_" + nmModuleCurrent + "_data"] = escape(ndModuleData);
  146.    if(strType == "bespoke" && ndModuleData.attributes.sandbox != "true")
  147.    {
  148.       Tardis.debug.addProcess("loadModules","-- module : bespoke/" + ndModuleData.getText());
  149.       mcPosition.loadMovie(Tardis.ASSETS_FOLDER + "bespoke/" + ndModuleData.getText());
  150.    }
  151.    else if(strType == "custom")
  152.    {
  153.       mcPosition.onReady;
  154.       mcPosition.onReady = function()
  155.       {
  156.          this.onComplete = function()
  157.          {
  158.             delete this.onComplete;
  159.             loadNextModule();
  160.          };
  161.          var initObject = Tardis.template.objModuleInitObjects[this];
  162.          for(var o in initObject)
  163.          {
  164.             this[o] = initObject[o];
  165.          }
  166.          delete Tardis.template.objModuleInitObjects[this];
  167.          this.onReady = null;
  168.          this.init();
  169.          this._parent.checkReadyState();
  170.       };
  171.       Tardis.debug.addProcess("loadModules","-- module : bespoke/" + ndModuleData.getText());
  172.       mcPosition.loadMovie(Tardis.ASSETS_FOLDER + "bespoke/" + ndModuleData.getText());
  173.    }
  174.    else
  175.    {
  176.       mcPosition.onReady;
  177.       mcPosition.onReady = function()
  178.       {
  179.          this.onComplete = function()
  180.          {
  181.             delete this.onComplete;
  182.             loadNextModule();
  183.          };
  184.          var initObject = Tardis.template.objModuleInitObjects[this];
  185.          for(var o in initObject)
  186.          {
  187.             this[o] = initObject[o];
  188.          }
  189.          delete Tardis.template.objModuleInitObjects[this];
  190.          this.onReady = null;
  191.          this.init();
  192.          this._parent.checkReadyState();
  193.       };
  194.       Tardis.debug.addProcess("loadModules","-- module : " + modulePath + strType + ".swf");
  195.       mcPosition.loadMovie(modulePath + strType + ".swf");
  196.    }
  197.    if(_root.EDIT_MODE == 1)
  198.    {
  199.       pageEditVars.send("../../../cms/edit.php","edit","POST");
  200.    }
  201.    nmModuleCurrent++;
  202. }
  203. function checkReadyState()
  204. {
  205.    nmModulesReady++;
  206.    if(nmModulesReady == nmModules)
  207.    {
  208.       onReady();
  209.    }
  210. }
  211. var objModuleInitObjects = {};
  212.